## Warning: No trace type specified and no positional attributes specified
## No trace type specified:
##   Based on info supplied, a 'scatter' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter
## No scatter mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode

test 2

plot degueu

{r persp, echo = FALSE} col <- RGB[,,1] + RGB[,,2] + RGB[,,3] rgb <- unique(c(RGB[,,1] + RGB[,,2] + RGB[,,3])) c <- c(NA, “#a020f0”, “#ffa500”, “#0000ff”, “#006400”, “#ffff00”, “#000000”, “#ff0000”) c <- c(NA, “blue”, “green”, “red”, “yellow”, “black”, “purple”,“orange”) for (i in 1:length(rgb)) { col[RGB[,,1] + RGB[,,2] + RGB[,,3] == rgb[i]] <- c[i] } col[is.na(col)] <- “white” persp(x = 10 * 1:dim(elev_mat)[1], y = 10 * 1:dim(elev_mat)[2], z = elev_mat, col = col, theta = 135, phi = 30, ltheta = -120, shade = 0.75, scale = FALSE, border = NA, box = FALSE) z = volcano col <- z col[z > 130] <- “red” col[z < 130] <- “blue” persp3d(10 * 1:100,10 * 1:dim(z)[2], elev_mat[1:87,1:61], theta = 135, phi = 30, col = col[1:87,1:61], scale = FALSE, ltheta = -120, shade = 0.75, border = NA, box = FALSE)

levelpersp <- function(x, y, z, colors=topo.colors, …) { ## getting the value of the midpoint zz <- (z[-1,-1] + z[-1,-ncol(z)] + z[-nrow(z),-1] + z[-nrow(z),-ncol(z)])/4 ## calculating the breaks breaks <- hist(zz, plot=FALSE)$breaks ## cutting up zz cols <- colors(length(breaks)-1) zzz <- cut(zz, breaks=breaks, labels=cols) ## plotting persp(x, y, z, col=as.character(zzz), …) ## return breaks and colors for the legend list(breaks=breaks, colors=cols) }

Example

x <- 1:317 y <- 1:257 f <- function(x,y) { r <- sqrt(x2+y2); 10 * sin(r)/r } z <- elev_mat levelpersp(x, y, z, theta = 30, phi = 30, expand = 0.5, border = NA) ```